package com.guaju.yueshangLife.activity;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.databinding.adapters.FrameLayoutBindingAdapter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.githang.statusbar.StatusBarCompat;
import com.guaju.yueshangLife.R;
import com.guaju.yueshangLife.base.MyAppcomActivity;
import com.guaju.yueshangLife.databinding.ActivityOrderNoteBinding;

public class OrderNoteActivity extends MyAppcomActivity {

    private ActivityOrderNoteBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this,R.layout.activity_order_note);
        StatusBarCompat.setStatusBarColor(this, getResources().getColor(R.color.white));
        initView();
    }

    private void initView() {
        TextView top_tv_title = binding.top.findViewById(R.id.top_tv_title);
        top_tv_title.setText("订单备注");
        FrameLayout fl_back = binding.top.findViewById(R.id.fl_back);
        fl_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        //TODO 字数监听
//        binding.etNote.setO
        binding.submitNotes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String note = binding.etNote.getText().toString().trim();
                if(TextUtils.isEmpty(note)){
                    Toast.makeText(OrderNoteActivity.this, "备注未填写", Toast.LENGTH_SHORT).show();
                }else{
                    Intent intent = getIntent();
                    intent.putExtra("note",note);
                    setResult(0,intent);
                    finish();
                }

            }
        });
    }

}
